package com.push.xu.xpush.util;

import java.util.Map;


import android.content.Context;
import android.os.Parcelable;

import com.push.xu.xpush.constant.PushAction;
import com.push.xu.xpush.entity.PushCommand;
import com.push.xu.xpush.entity.PushMsg;

public class PushRepeater {
	
	/**
     * Repeater instructions operating results
     * @param context
     * @param extraMsg 额外信息
     * @param error 错误信息
     */
	public static void transmitCommandResult(Context context, String token
            , String extraMsg, String error){
        transmit(context, PushAction.RECEIVE_COMMAND_RESULT
                , new PushCommand(token, extraMsg, error));
    }

    /**
     * Repeater passthrough message
     * @param context
     * @param msg
     * @param extraMsg
     */
    public static void transmitMessage(Context context, String msg
            , String extraMsg, Map<String,String> keyValue){
        transmit(context, PushAction.RECEIVE_MESSAGE
                , new PushMsg(0, null, null, msg, extraMsg,keyValue));
    }

    /**
     * Repeater the notification bar click event
     * @param context
     * @param notifyId
     * @param title
     * @param content
     * @param extraMsg
     */
    public static void transmitNotificationClick(Context context,int notifyId,String title
            ,String content,String extraMsg,Map<String,String> keyValue){
        transmit(context, PushAction.RECEIVE_NOTIFICATION_CLICK
                , new PushMsg(notifyId, title, content, null, extraMsg,keyValue));
    }

    /**
     * Repeater notice
     *
     * @param context
     * @param notifyId
     * @param title
     * @param content
     * @param extraMsg
     */
    public static void transmitNotification(Context context, int notifyId, String title
            , String content, String extraMsg, Map<String, String> keyValue) {
        transmit(context, PushAction.RECEIVE_NOTIFICATION
                , new PushMsg(notifyId, title, content, null, extraMsg, keyValue));
    }

    /**
     * The main method to repeater information
     * @param context
     * @param action
     * @param data
     */
    private static void transmit(Context context, String action, Parcelable data) {
        TransmitDataManager.sendPushData(context, action, data);
    }
}
